import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
import state from './state'
import mutations from './mutations'
// createLogger会在我们每次通过mutation修改state时会在控制台打印一个logger(也就是告诉我们这条修改记录是什么)
import createLogger from 'vuex/dist/logger'

Vue.use(Vuex)

// 也就是我们在线下调试debug为true, 开启对vuex的严格模式, 会检测state修改是不是来源于mutation, 否则报警告
const debug = process.env.NODE_ENV !== 'production'

export default new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  strict: debug,
  plugins: debug ? [createLogger()] : []
})
